﻿
using Microsoft.ProjectOxford.Common.Contract;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Microsoft.ProjectOxford.Face.Controls
{
    /// <summary>
    /// Face view model
    /// </summary>
    public class FaceInfo : INotifyPropertyChanged
    {
        #region Fields

        /// <summary>
        /// 性别
        /// </summary>
        private string _gender;

        /// <summary>
        /// 年龄
        /// </summary>
        private string _age;

        /// <summary>
        /// 信任度
        /// </summary>
        private double _confidence;

        /// <summary>
        /// 人名
        /// </summary>
        private string _personName;

        /// <summary>
        /// 人ID
        /// </summary>
        private string _personId;

        /// <summary>
        /// 脸部高度
        /// </summary>
        private int _height;

        /// <summary>
        /// 脸部位置X
        /// </summary>
        private int _left;

        /// <summary>
        /// 脸部位置Y
        /// </summary>
        private int _top;

        /// <summary>
        /// 面宽
        /// </summary>
        private int _width;

        /// <summary>
        /// 面部头发
        /// </summary>
        private string _facialHair;

        /// <summary>
        /// 眼镜类型
        /// </summary>
        private string _glasses;

        /// <summary>
        /// 头姿势
        /// </summary>
        private string _headPose;

        /// <summary>
        /// 情感
        /// </summary>
        private string _emotion;

        /// <summary>
        /// 情感详细信息
        /// </summary>
        private EmotionScores _emotionScores;

        /// <summary>
        /// 人脸图片
        /// </summary>
        private string _faceImgname;

        #endregion Fields

        #region Events

        /// <summary>
        /// Implement INotifyPropertyChanged interface
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion Events

        #region Properties

        /// <summary>
        /// 设置和取得性别
        /// </summary>
        public string Gender
        {
            get
            {
                return _gender;
            }

            set
            {
                _gender = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 设置和取得年龄
        /// </summary>
        public string Age
        {
            get
            {
                return _age;
            }

            set
            {
                _age = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 设置和取得信任度
        /// </summary>
        public double Confidence
        {
            get
            {
                return _confidence;
            }

            set
            {
                _confidence = value;
                OnPropertyChanged<double>();
            }
        }

        /// <summary>
        /// 获取图像上的矩形
        /// </summary>
        public System.Windows.Int32Rect UIRect
        {
            get
            {
                return new System.Windows.Int32Rect(Left, Top, Width, Height);
            }
        }

        /// <summary>
        /// 设置和取得图片路径
        /// </summary>
        public string ImagePath
        {
            get;
            set;
        }

        /// <summary>
        /// 设置和取得人脸ID
        /// </summary>
        public string FaceId
        {
            get;
            set;
        }

        /// <summary>
        /// 设置和取得人ID
        /// </summary>
        public string PersonId
        {
            get
            {
                return _personId;
            }
            set
            {
                _personId = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 设置和取得人名
        /// </summary>
        public string PersonName
        {
            get
            {
                return _personName;
            }
            set
            {
                _personName = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 设置和取得脸部高度
        /// </summary>
        public int Height
        {
            get
            {
                return _height;
            }
            set
            {
                _height = value;
                OnPropertyChanged<int>();
            }
        }

        /// <summary>
        /// 获取或设置脸部位置X
        /// </summary>
        public int Left
        {
            get
            {
                return _left;
            }
            set
            {
                _left = value;
                OnPropertyChanged<int>();
            }
        }

        /// <summary>
        /// 获取或设置脸部位置Y
        /// </summary>
        public int Top
        {
            get
            {
                return _top;
            }
            set
            {
                _top = value;
                OnPropertyChanged<int>();
            }
        }

        /// <summary>
        /// 获取或设置面宽
        /// </summary>
        public int Width
        {
            get
            {
                return _width;
            }

            set
            {
                _width = value;
                OnPropertyChanged<int>();
            }
        }

        /// <summary>
        /// 获取或设置面部头发显示字符串
        /// </summary>
        public string FacialHair
        {
            get
            {
                return _facialHair;
            }

            set
            {
                _facialHair = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 获取或设置一个指示眼镜类型的值
        /// </summary>
        public string Glasses
        {
            get
            {
                return _glasses;
            }

            set
            {
                _glasses = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 获取或设置一个指示头姿势值的值。
        /// </summary>
        public string HeadPose
        {
            get { return _headPose; }
            set
            {
                _headPose = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 情感
        /// </summary>
        public string Emotion
        {
            get { return _emotion; }
            set
            {
                _emotion = value;
                OnPropertyChanged<string>();
            }
        }

        /// <summary>
        /// 情感详细信息
        /// </summary>
        public EmotionScores EmotionScores
        {
            get
            {
                return _emotionScores;
            }

            set
            {
                _emotionScores = value;
            }
        }

        /// <summary>
        /// 人脸图片
        /// </summary>
        public string FaceImgname
        {
            get
            {
                return _faceImgname;
            }

            set
            {
                _faceImgname = value;
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// NotifyProperty Helper functions
        /// </summary>
        /// <typeparam name="T">property type</typeparam>
        /// <param name="caller">property change caller</param>
        private void OnPropertyChanged<T>([CallerMemberName]string caller = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(caller));
        }

        #endregion Methods
    }
}